From 05dd2abf289c312799bfa1bdaee4f86f52f6f7a1 Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 30 Sep 2003 13:55:14 +0000 Subject: [PATCH] Add Mark Bradley's tool to generate a windows cmd file from testo. --- gpsbabel/mingw/Makefile | 9 +- gpsbabel/mingw/mkwintesto.c | 335 +++++++++++++++++++++++++++++++++ gpsbabel/mingw/wintesto.cmd | 364 ++++++++++++++++++++++++++++++++++++ 3 files changed, 706 insertions(+), 2 deletions(-) create mode 100644 gpsbabel/mingw/mkwintesto.c create mode 100644 gpsbabel/mingw/wintesto.cmd diff --git a/gpsbabel/mingw/Makefile b/gpsbabel/mingw/Makefile index d43e8582c..469c75f30 100644 --- a/gpsbabel/mingw/Makefile +++ b/gpsbabel/mingw/Makefile @@ -1,9 +1,9 @@ CC=/home/robertl/cross-tools/bin/i386-mingw32msvc-gcc VPATH=.. -FILES=gpsbabel.exe libexpat.dll ../win32/gpsbabelfront.exe ../README* +FILES=gpsbabel.exe libexpat.dll ../win32/gpsbabelfront.exe ../README* ../COPYING -gpsbabel.exe: +gpsbabel.exe: wintesto.cmd include ../Makefile CFLAGS=-Iinclude -I../coldsync -O @@ -13,3 +13,8 @@ gpsbabel.exe: $(OBJS) cp gpsbabel.exe /tmp zip -j /tmp/gpsbabel-$(VERSIOND).zip $(FILES) +mkwintesto: mkwintesto.c + /usr/bin/cc mkwintesto.c ../util.c -o mkwintesto + +wintesto.cmd: mkwintesto + ./mkwintesto ../testo diff --git a/gpsbabel/mingw/mkwintesto.c b/gpsbabel/mingw/mkwintesto.c new file mode 100644 index 000000000..2f6ca99ff --- /dev/null +++ b/gpsbabel/mingw/mkwintesto.c @@ -0,0 +1,335 @@ +/* + File for "converting" GPSBabel's testo shell script into + MS Windows NT/2000/XP command script. + + It is limited to: + - testo using the shell variable PNAME for the executable program being tested + - testo using ${TMPDIR} for the temporary directory in which test files are created + - testo using compare as the name of a shell function for comparing test results + - no other shell script conversion is performed apart from whole line comments; + unconverted script is discarded, not even included as comments in the output + + Copyright (C) 2003 Mark Bradley, mrcb.sf.gpsb@osps.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + */ + + +#include +#include + +#define LINELENGTH 200 +#define MYNAME "MkWinTesto" + +// ------------------------------------------------------------------------------------ +int f_outputLine ( + char *pcWhat, + FILE *pfWhere) +{ + int iLength; + int iThisChar; + + // =========================== + // Returns 0 is output has new line + // Returns 1 is line ended on \ for continuation and no new line + + iLength = strlen(pcWhat); + if (iLength > 2) { + if ((*(pcWhat+iLength-3) == '\\') && + (*(pcWhat+iLength-2) == '\r') && + (*(pcWhat+iLength-1) == '\n')) { + + for (iThisChar=0; iThisChar < iLength-3; iThisChar++) + fputc(*(pcWhat+iThisChar), pfWhere); + return 1; + } + } + if (iLength > 1) { + if ((*(pcWhat+iLength-2) == '\\') && + (*(pcWhat+iLength-1) == '\n')) { + + for (iThisChar=0; iThisChar < iLength-2; iThisChar++) + fputc(*(pcWhat+iThisChar), pfWhere); + return 1; + } + } + if (iLength > 0) { + if (*(pcWhat+iLength-1) == '\\') { + + for (iThisChar=0; iThisChar < iLength-1; iThisChar++) + fputc(*(pcWhat+iThisChar), pfWhere); + return 1; + } + } + + fputs(pcWhat, pfWhere); + fputs("\r\n", pfWhere); + return 0; +} + +// ------------------------------------------------------------------------------------ +int main( + int argc, + char *argv[]) +{ + char acLineIn[LINELENGTH]; + char acLineOut[LINELENGTH]; + + int iThisChar; + int iStart; + int iTarget; + int iTranslateQuotes; + int iQuoteCount; + int iPrevLineContinues = 0; + + FILE *pfTestoIn; + FILE *pfTestoOut; + + // =========================== + + pfTestoIn = fopen(argv[1], "rb"); + + if (pfTestoIn == NULL) { + fatal(MYNAME ": %s for reading\n",argv[1]); + } + else { + pfTestoOut = fopen ("wintesto.cmd", "wb"); + if (pfTestoOut == NULL) { + fatal (MYNAME ": wintesto.cmd for writing\n"); + } + else { + + // Output the .CMD preamble + f_outputLine("REM", pfTestoOut); + f_outputLine("REM Simple Windows NT/2000/XP .cmd version of GPSBabel testo script", pfTestoOut); + f_outputLine("REM", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine("SET TMPDIR=%TEMP%\\WINTESTO", pfTestoOut); + f_outputLine("MKDIR %TMPDIR% 2>NUL:", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine("GOTO :REALSTART", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine(":COMPARE", pfTestoOut); + f_outputLine("SET PARAM1=%1", pfTestoOut); + f_outputLine("SET PARAM2=%2", pfTestoOut); + f_outputLine("REM Test if param2 was a dir rather than a file, if so add a \\* to make fc work", pfTestoOut); + f_outputLine("FOR %%A IN (%2) DO IF \"d--------\"==\"%%~aA\" SET PARAM2=%2\\*", pfTestoOut); + f_outputLine("FOR /f \"delims=\" %%a IN ('fc %PARAM1% %PARAM2%') DO IF \"x%%a\"==\"xFC: no differences encountered\" GOTO :EOF", pfTestoOut); + f_outputLine("ECHO %* are not the same - pausing. ^C to quit if required", pfTestoOut); + f_outputLine("PAUSE", pfTestoOut); + f_outputLine("GOTO :EOF", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine("REM ==================================", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine(":SORTandCOMPARE", pfTestoOut); + f_outputLine("SORT <%1 >%TMPDIR%\\s1", pfTestoOut); + f_outputLine("SORT <%2 >%TMPDIR%\\s2", pfTestoOut); + f_outputLine("CALL :COMPARE %TMPDIR%\\s1 %TMPDIR%\\s2", pfTestoOut); + f_outputLine("GOTO :EOF", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine("REM ==================================", pfTestoOut); + f_outputLine("", pfTestoOut); + f_outputLine(":REALSTART", pfTestoOut); + f_outputLine("", pfTestoOut); + + + + while (! feof(pfTestoIn)) { + // Read in the next line or stop if done + fgets(acLineIn, LINELENGTH-1, pfTestoIn); + if (acLineIn == NULL) break; + + // Is the whole line a comment? Replace the hash with REM and output the rest + if (acLineIn[0] == '#') { + acLineOut[0]='\0'; + strcat (acLineOut,"REM"); + // Strip out any ending new lines + for (iThisChar=1; iThisChar 0) || + (iPrevLineContinues == 1)) { + + if (iStart == 0) { + // Didn't match, so can only possibly be a continued line + // Skip spaces, then process the rest of line as "normal" + for (iThisChar=0; iThisChar 0) ? 0 : 1; + iTarget--; + continue; + } + if (acLineIn[iThisChar] == '%') { + if (iQuoteCount == 1) { + // Need to double up the number of %s + acLineOut[iTarget+iThisChar-iStart] = '%'; + iTarget++; + } + // This also caters for where we're not in quotes, + // so must just copy the % once + acLineOut[iTarget+iThisChar-iStart] = '%'; + continue; + } + if (acLineIn[iThisChar] == '>') { + if (acLineIn[iThisChar-1] == ' ') { + // Need to remove any spaces between echo and redirection + // as NT/2000/XP adds this to the output and mostly this is NOT wanted + iTarget--; + } + acLineOut[iTarget+iThisChar-iStart] = '>'; + continue; + } + if (strncmp("${TMPDIR}",acLineIn+iThisChar,9) == 0) { + strcpy(acLineOut+iTarget+iThisChar-iStart,"%TMPDIR%"); + // %TMPDIR% is one char shorter than ${TMPDIR} + iTarget--; + // skip forward to the end of the string matched + // (less one as the loop will add one) + iThisChar += 8; + } else if (acLineIn[iThisChar] == '/') { + acLineOut[iTarget+iThisChar-iStart] = '\\'; + } else { + // part of a literal, so copy the text + acLineOut[iTarget+iThisChar-iStart] = acLineIn[iThisChar]; + } + } // for + iPrevLineContinues = f_outputLine(acLineOut, pfTestoOut); + // fputs("\r\n", pfTestoOut); + } + else { + // We didn't match the start of the line, so + // - if blank, print it + + if ((acLineIn[0] == '\n') || + (acLineIn[0] == '\0') || + ((acLineIn[0] == '\r') && (acLineIn[1] == '\n') && (acLineIn[2] == '\0'))) { + iPrevLineContinues = f_outputLine("", pfTestoOut); + } + + } // else... didn't match a start of line - so check rest of line + + } // else ... catchall to mathing things on the start of the line + + } // while + + // We're done + fclose(pfTestoIn); + fclose(pfTestoOut); + } + } +} diff --git a/gpsbabel/mingw/wintesto.cmd b/gpsbabel/mingw/wintesto.cmd new file mode 100644 index 000000000..9d835bc92 --- /dev/null +++ b/gpsbabel/mingw/wintesto.cmd @@ -0,0 +1,364 @@ +REM +REM Simple Windows NT/2000/XP .cmd version of GPSBabel testo script +REM + +SET TMPDIR=%TEMP%\WINTESTO +MKDIR %TMPDIR% 2>NUL: + +GOTO :REALSTART + +:COMPARE +SET PARAM1=%1 +SET PARAM2=%2 +REM Test if param2 was a dir rather than a file, if so add a \* to make fc work +FOR %%A IN (%2) DO IF "d--------"=="%%~aA" SET PARAM2=%2\* +FOR /f "delims=" %%a IN ('fc %PARAM1% %PARAM2%') DO IF "x%%a"=="xFC: no differences encountered" GOTO :EOF +ECHO %* are not the same - pausing. ^C to quit if required +PAUSE +GOTO :EOF + +REM ================================== + +:SORTandCOMPARE +SORT <%1 >%TMPDIR%\s1 +SORT <%2 >%TMPDIR%\s2 +CALL :COMPARE %TMPDIR%\s1 %TMPDIR%\s2 +GOTO :EOF + +REM ================================== + +:REALSTART + + +SET PNAME=.\gpsbabel +IF NOT EXIST %PNAME% ECHO Can't find %PNAME%&& GOTO :EOF + + + + + +REM Geocaching .loc +DEL %TMPDIR%\gl.loc +%PNAME% -i geo -f geocaching.loc -o geo -F %TMPDIR%\gl.loc +CALL :COMPARE %TMPDIR%\gl.loc reference + +REM GPSUtil +DEL %TMPDIR%\gu.wpt +%PNAME% -i geo -f geocaching.loc -o gpsutil -F %TMPDIR%\gu.wpt +CALL :COMPARE %TMPDIR%\gu.wpt reference + +REM GPSman +DEL %TMPDIR%\gm.gm %TMPDIR%\gm.gm+ +%PNAME% -i geo -f geocaching.loc -o gpsman -F %TMPDIR%\gm.gm +%PNAME% -i gpsman -f %TMPDIR%\gm.gm -o gpsutil -F %TMPDIR%\gm.gm+ +CALL :COMPARE %TMPDIR%\gm.gm+ %TMPDIR%\gu.wpt + +REM GPX +DEL %TMPDIR%\gl.gpx %TMPDIR%\gpx.gpx +%PNAME% -i geo -f geocaching.loc -o gpx -F %TMPDIR%\gl.gpx +%PNAME% -i gpx -f %TMPDIR%\gl.gpx -o gpsutil -F %TMPDIR%\gpx.gpx +CALL :COMPARE %TMPDIR%\gpx.gpx %TMPDIR%\gu.wpt + +REM Magellan Mapsend +DEL %TMPDIR%\mm.mapsend %TMPDIR%\mm.gps +%PNAME% -i geo -f geocaching.loc -o mapsend -F %TMPDIR%\mm.mapsend +%PNAME% -i mapsend -f %TMPDIR%\mm.mapsend -o gpsutil -F %TMPDIR%\mm.gps +CALL :COMPARE %TMPDIR%\mm.gps %TMPDIR%\gu.wpt + +REM Magellan serial +REM TODO + +REM Tiger +REM This one is a little tacky, becuase it's a very lossy format. +REM so we simply test we can write it, and then read it and write it and +REM get an identical file back. +DEL %TMPDIR%\tiger +%PNAME% -i geo -f geocaching.loc -o tiger -F %TMPDIR%\tiger +%PNAME% -i tiger -f %TMPDIR%\tiger -o tiger -F %TMPDIR%\tiger2 +CALL :COMPARE %TMPDIR%\tiger %TMPDIR%\tiger2 + +REM CSV (Comma separated value) data. + +%PNAME% -i geo -f geocaching.loc -o csv -F %TMPDIR%\csv.csv +%PNAME% -i csv -f %TMPDIR%\csv.csv -o csv -F %TMPDIR%\csv2.csv +CALL :COMPARE %TMPDIR%\csv2.csv %TMPDIR%\csv.csv + +REM +REM Delorme TopoUSA 4 is a CSV strain. +REM +DEL %TMPDIR%\xmap-1.gpx %TMPDIR%\xmap-2.gpx %TMPDIR%\xmap +%PNAME% -i xmap -f reference\xmap -o xmap -F %TMPDIR%\xmap +%PNAME% -i xmap -f reference\xmap -o gpx -F %TMPDIR%\xmap-1.gpx +%PNAME% -i xmap -f %TMPDIR%\xmap -o gpx -F %TMPDIR%\xmap-2.gpx +CALL :COMPARE %TMPDIR%\xmap-1.gpx %TMPDIR%\xmap-2.gpx +CALL :COMPARE reference\xmap %TMPDIR%\xmap + +REM PCX (Garmin mapsource import) file format +DEL %TMPDIR%\mm.pcx %TMPDIR%\pcx.gps +%PNAME% -i geo -f geocaching.loc -o pcx -F %TMPDIR%\mm.pcx +%PNAME% -i pcx -f %TMPDIR%\mm.pcx -o gpsutil -F %TMPDIR%\pcx.gps +CALL :COMPARE %TMPDIR%\mm.gps %TMPDIR%\gu.wpt + +REM Magellan file format +%PNAME% -i magellan -f reference\magfile -o magellan -F %TMPDIR%\magfile +CALL :COMPARE %TMPDIR%\magfile reference\magfile + +REM Navitrak DNA marker format +%PNAME% -i dna -f reference\dnatest.txt -o dna -F %TMPDIR%\dnatest.txt +CALL :COMPARE %TMPDIR%\dnatest.txt reference\dnatest.txt + +REM PSP (PocketStreets 2002 Pushpin (.PSP)) file format. Use mxf as an +REM intermediate format to avoid binary FP anomalies on compareerent platforms. +DEL %TMPDIR%\psp.mxf %TMPDIR%\mxf.psp +%PNAME% -i psp -f reference\ps.psp -o mxf -F %TMPDIR%\psp.mxf +%PNAME% -i geo -f geocaching.loc -o mxf -F %TMPDIR%\mxf.psp +CALL :COMPARE %TMPDIR%\psp.mxf %TMPDIR%\mxf.psp + +REM MXF (Maptech Exchange Format) file format +DEL %TMPDIR%\mx.mxf %TMPDIR%\mxf.mxf +%PNAME% -i mxf -f reference\mxf.mxf -o mxf -F %TMPDIR%\mx.mxf +%PNAME% -i mxf -f %TMPDIR%\mx.mxf -o mxf -F %TMPDIR%\mxf.mxf +CALL :COMPARE %TMPDIR%\mxf.mxf reference + +REM tmpro (TopoMapPro Places) file format +DEL %TMPDIR%\topomappro.txt %TMPDIR%\mxf.mxf +%PNAME% -i tmpro -f reference\topomappro.txt -o tmpro -F %TMPDIR%\tmp.txt +%PNAME% -i tmpro -f %TMPDIR%\tmp.txt -o tmpro -F %TMPDIR%\topomappro.txt +CALL :COMPARE %TMPDIR%\topomappro.txt reference + +REM TPG (NG Topo!) file format +REM This is hard to test as the datum conversions create minute +REM inconsistencies in the coordinates. So.. we test our i/o +REM against a format that rounds higher than we care to compare +REM for binary data. +DEL %TMPDIR%\topo.mxf %TMPDIR%\tpg.mxf %TMPDIR%\geo.tpg +%PNAME% -i geo -f geocaching.loc -o tpg -F %TMPDIR%\geo.tpg +%PNAME% -i tpg -f %TMPDIR%\geo.tpg -o mxf -F %TMPDIR%\tpg.mxf +%PNAME% -i tpg -f reference\tpg.tpg -o mxf -F %TMPDIR%\topo.mxf +CALL :COMPARE %TMPDIR%\tpg.mxf %TMPDIR%\topo.mxf + +REM OZI (OziExplorer 1.1) file format +DEL %TMPDIR%\oz.ozi %TMPDIR%\ozi.ozi +%PNAME% -i ozi -f reference\ozi.ozi -o ozi -F %TMPDIR%\oz.ozi +%PNAME% -i ozi -f %TMPDIR%\oz.ozi -o ozi -F %TMPDIR%\ozi.ozi +CALL :COMPARE %TMPDIR%\ozi.ozi reference + +REM Holux support is a little funky to test. Becuase it loses precision, +REM if we convert it to another format, we lose accuracy (rounding) in the +REM coords, so converting it so something else and comparing it never works. +REM So we verify that we can read the reference and write it and get an +REM identical reference. +%PNAME% -i holux -f reference\paris.wpo -o holux -F %TMPDIR%\paris.wpo +CALL :COMPARE reference\paris.wpo %TMPDIR%\paris.wpo + +REM Magellan NAV Companion for PalmOS +REM This format is hard to test, because each record and the database itself +REM contains the time of creation, so two otherwise identical files won't +REM compare accurately. In any case, the files are binary so compare wouldn't +REM like them. So, we convert the reference file to gpsutil and the converted +REM file to gpsutil and make sure they're the same, and that they're the same +REM as one converted on a known-working installation. Unfortunately, this does +REM not verify that the appinfo block was written correctly. However, it does +REM successfully test for some endianness errors that might otherwise go +REM unnoticed. +DEL %TMPDIR%\magnav.pdb %TMPDIR%\magnav.gpu %TMPDIR%\magnavt.gpu +%PNAME% -i geo -f geocaching.loc -o magnav -F %TMPDIR%\magnav.pdb +%PNAME% -i magnav -f %TMPDIR%\magnav.pdb -o gpsutil -F %TMPDIR%\magnav.gpu +%PNAME% -i magnav -f reference\magnav.pdb -o gpsutil -F %TMPDIR%\magnavt.gpu +CALL :COMPARE %TMPDIR%\magnavt.gpu %TMPDIR%\magnav.gpu +CALL :COMPARE reference\gu.wpt %TMPDIR%\magnav.gpu + +REM GPSPilot Tracker for PalmOS +REM This test is eerily similar to the NAV Companion test. In fact, the +REM converted reference file (magnavr.gpu) is identical. +DEL %TMPDIR%\gpspilot.pdb %TMPDIR%\gpspilot.gpu %TMPDIR%\gpspil_t.gpu +%PNAME% -i geo -f geocaching.loc -o gpspilot -F %TMPDIR%\gpspilot.pdb +%PNAME% -i gpspilot -f %TMPDIR%\gpspilot.pdb -o gpsutil -F %TMPDIR%\gpspilot.gpu +%PNAME% -i gpspilot -f reference\gpspilot.pdb -o gpsutil -F %TMPDIR%\gpspil_t.gpu +CALL :COMPARE %TMPDIR%\gpspil_t.gpu %TMPDIR%\gpspilot.gpu +CALL :COMPARE reference\gu.wpt %TMPDIR%\gpspilot.gpu + +REM Cetus GPS for PalmOS +REM This test is also similar to the NAV Companion test. +DEL %TMPDIR%\cetus.pdb %TMPDIR%\cetus.gpu %TMPDIR%\cetust.gpu +%PNAME% -i geo -f geocaching.loc -o cetus -F %TMPDIR%\cetus.pdb +%PNAME% -i cetus -f %TMPDIR%\cetus.pdb -o gpsutil -F %TMPDIR%\cetus.gpu +%PNAME% -i cetus -f reference\cetus.pdb -o gpsutil -F %TMPDIR%\cetust.gpu +CALL :COMPARE %TMPDIR%\cetust.gpu %TMPDIR%\cetus.gpu +CALL :COMPARE reference\cetus.gpu %TMPDIR%\cetus.gpu + +REM QuoVadis GPS for PalmOS +REM This test is derived from the Cetus test above. +DEL %TMPDIR%\quovadis.pdb %TMPDIR%\quovadis.gpu %TMPDIR%\quovadist.gpu +%PNAME% -i geo -f geocaching.loc -o quovadis -F %TMPDIR%\quovadis.pdb +%PNAME% -i quovadis -f %TMPDIR%\quovadis.pdb -o gpsutil -F %TMPDIR%\quovadis.gpu +%PNAME% -i quovadis -f reference\quovadis.pdb -o gpsutil -F %TMPDIR%\quovadist.gpu +CALL :COMPARE %TMPDIR%\quovadist.gpu %TMPDIR%\quovadis.gpu +CALL :COMPARE reference\quovadis.gpu %TMPDIR%\quovadis.gpu + +REM GpsDrive +DEL %TMPDIR%\gpsdrive.txt +%PNAME% -i geo -f geocaching.loc -o gpsdrive -F %TMPDIR%\gpsdrive.txt +CALL :COMPARE %TMPDIR%\gpsdrive.txt reference +%PNAME% -i gpsdrive -f reference\gpsdrive.txt -o gpsdrive -F %TMPDIR%\gpsdrive2.txt +CALL :COMPARE %TMPDIR%\gpsdrive2.txt reference\gpsdrive.txt + +REM XMapHH Street Atlas USA file format +DEL %TMPDIR%\xmapwpt.wpt %TMPDIR%\xmapwpt.xmapwpt +%PNAME% -i xmapwpt -f reference\xmapwpt.wpt -o xmapwpt -F %TMPDIR%\xmapwpt.xmapwpt +%PNAME% -i xmapwpt -f %TMPDIR%\xmapwpt.xmapwpt -o xmapwpt -F %TMPDIR%\xmapwpt.wpt +CALL :COMPARE %TMPDIR%\xmapwpt.wpt reference + +REM XCSV +REM Test that we can parse a style file, and read and write data in the +REM same xcsv format (a complete test is virtually impossible). +ECHO RECORD_DELIMITER NEWLINE> %TMPDIR%\testo.style +ECHO FIELD_DELIMITER COMMA>> %TMPDIR%\testo.style +ECHO BADCHARS COMMA>> %TMPDIR%\testo.style +ECHO PROLOGUE Header>> %TMPDIR%\testo.style +ECHO EPILOGUE Footer>> %TMPDIR%\testo.style +ECHO IFIELD SHORTNAME,,%%s>> %TMPDIR%\testo.style +ECHO IFIELD LAT_DIRDECIMAL,,%%c%%lf>> %TMPDIR%\testo.style +ECHO IFIELD LON_DECIMALDIR,,%%lf%%c>> %TMPDIR%\testo.style +DEL %TMPDIR%\xcsv.geo %TMPDIR%\xcsv.xcsv +%PNAME% -i geo -f geocaching.loc -o xcsv,style=%TMPDIR%\testo.style -F %TMPDIR%\xcsv.geo +%PNAME% -i xcsv,style=%TMPDIR%\testo.style -f %TMPDIR%\xcsv.geo -o xcsv,style=%TMPDIR%\testo.style -F %TMPDIR%\xcsv.xcsv +CALL :COMPARE %TMPDIR%\xcsv.geo %TMPDIR%\xcsv.xcsv + +REM Garmin Mapsource This is a binary format with some undocumented +REM fields. This test is therefore intentionally vague. We read a file, +REM convert it to GPX, then write a file as MPS, then read it back and +REM write it as GPX and compare them. Since we're writing both GPX files +REM ourselves from the same version, we're immune to changes in our own +REM GPX output. + +%PNAME% -i mapsource -f reference\mapsource.mps -o gpx -F %TMPDIR%\ms1.gpx +%PNAME% -i mapsource -f reference\mapsource.mps -o mapsource -F %TMPDIR%\ms.mps +%PNAME% -i mapsource -f %TMPDIR%\ms.mps -o gpx -F %TMPDIR%\ms2.gpx +CALL :COMPARE %TMPDIR%\ms1.gpx %TMPDIR%\ms2.gpx +REM +REM MRCB mapsource track test +REM +DEL %TMPDIR%\mps-track.mps +%PNAME% -t -i mapsource -f reference\track\mps-track.mps -o mapsource -F %TMPDIR%\mps-track.mps +CALL :COMPARE %TMPDIR%\mps-track.mps reference\track +REM +REM Geocaching Database is a binary Palm format that, like the GPX variants +REM has a zillion "equivalent" encodings of any given record set. So we +REM read the reference file, spin it to GPX and back to GCDB and then spin +REM that one to GPX. +REM + +%PNAME% -i gcdb -f reference\GeocachingDB.PDB -o gpx -F %TMPDIR%\gcdb1.gpx -o gcdb -F %TMPDIR%\gcdb1.pdb +%PNAME% -i gpx -f %TMPDIR%\gcdb1.gpx -o gpx -F %TMPDIR%\gcdb2.gpx +CALL :COMPARE %TMPDIR%\gcdb1.gpx %TMPDIR%\gcdb1.gpx + +REM +REM Duplicate filter - Since filters have no format of their own, we use csv +REM as an intermediate format for testing the filter. +REM +DEL %TMPDIR%\filterdupe.csv1 %TMPDIR%\filterdupe.csv2 +%PNAME% -i geo -f geocaching.loc -o csv -F %TMPDIR%\filterdupe.csv1 +%PNAME% -i geo -f geocaching.loc -f geocaching.loc -x duplicate,shortname -o csv -F %TMPDIR%\filterdupe.csv2 +CALL :SORTandCOMPARE %TMPDIR%\filterdupe.csv1 %TMPDIR%\filterdupe.csv2 + +REM +REM Position filter - Since very small distances are essentialy a duplicate +REM position filter, we can test very similarly to the duplicate filter. +REM +DEL %TMPDIR%\filterpos.csv1 %TMPDIR%\filterpos.csv2 +%PNAME% -i geo -f geocaching.loc -o csv -F %TMPDIR%\filterpos.csv1 +%PNAME% -i geo -f geocaching.loc -f geocaching.loc -x position,distance=5f -o csv -F %TMPDIR%\filterpos.csv2 +CALL :SORTandCOMPARE %TMPDIR%\filterpos.csv1 %TMPDIR%\filterpos.csv2 + +REM +REM Radius filter +REM +DEL %TMPDIR%\radius.csv +%PNAME% -i geo -f geocaching.loc -x radius,lat=35.9720,lon=-87.1347,distance=14.7 -o csv -F %TMPDIR%\radius.csv +CALL :COMPARE %TMPDIR%\radius.csv reference +REM +REM magellan SD card waypoint / route format +REM +DEL %TMPDIR%\magellan.rte +%PNAME% -r -i magellan -f reference\route\magellan.rte -o magellan -F %TMPDIR%\magellan.rte +CALL :COMPARE %TMPDIR%\magellan.rte reference\route\magellan.rte + +REM +REM GPX routes -- since GPX contains a date stamp, tests will always +REM fail, so we use magellan as an interim format... +REM +DEL %TMPDIR%\gpxroute.gpx %TMPDIR%\maggpx.rte +%PNAME% -r -i gpx -f reference\route\route.gpx -o gpx -F %TMPDIR%\gpxroute.gpx +%PNAME% -r -i gpx -f %TMPDIR%\gpxroute.gpx -o magellan -F %TMPDIR%\maggpx.rte +CALL :COMPARE %TMPDIR%\maggpx.rte reference\route\magellan.rte + +REM +REM MAPSEND waypoint / route format +REM +DEL %TMPDIR%\route.mapsend +%PNAME% -r -i mapsend -f reference\route\route.mapsend -o mapsend -F %TMPDIR%\route.mapsend +CALL :COMPARE %TMPDIR%\route.mapsend reference\route +REM +REM MAPSEND track format +REM +DEL %TMPDIR%\mapsend.trk +%PNAME% -t -i mapsend -f reference\track\mapsend.trk -o mapsend -F %TMPDIR%\mapsend.trk +CALL :COMPARE %TMPDIR%\mapsend.trk reference\track +REM +REM copilot +REM +DEL %TMPDIR%\copilot.pdb +%PNAME% -i copilot -f reference\UKultralight.pdb -o copilot -F %TMPDIR%\cop.pdb +%PNAME% -i copilot -f reference\UKultralight.pdb -o gpx -F %TMPDIR%\cop1.gpx +%PNAME% -i copilot -f %TMPDIR%\cop.pdb -o gpx -F %TMPDIR%\cop2.gpx +CALL :COMPARE %TMPDIR%\cop1.gpx %TMPDIR%\cop2.gpx + +REM +REM EasyGPS. Another binary format. +REM +DEL %TMPDIR%\easy.loc +%PNAME% -i easygps -f reference\easygps.loc -o easygps -F %TMPDIR%\ez.loc +%PNAME% -i easygps -f reference\easygps.loc -o gpx -F %TMPDIR%\ez1.gpx +%PNAME% -i easygps -f %TMPDIR%\ez.loc -o gpx -F %TMPDIR%\ez2.gpx +CALL :COMPARE %TMPDIR%\ez1.gpx %TMPDIR%\ez2.gpx + +REM +REM GPilotS. A Palm format. Another binary format that +REM +REM rm -f ${TMPDIR/gpilots.l +REM${PNAME} -i easygps -f reference/gpilots.pdb -o gpx -F ${TMPDIR}/gp.gpx +%PNAME% -i geo -f geocaching.loc -o gpilots -F %TMPDIR%\blah.pdb +%PNAME% -i gpilots -f %TMPDIR%\blah.pdb -o gpx -F %TMPDIR%\1.gpx +%PNAME% -i gpilots -f reference\gpilots.pdb -o gpx -F %TMPDIR%\2.gpx +CALL :COMPARE %TMPDIR%\1.gpx %TMPDIR%\2.gpx +REM${PNAME} -i easygps -f reference/gpilots.pdb -o gpx -F ${TMPDIR}/gp.gpx + +REM +REM Navicache. +%PNAME% -i navicache -f reference\navicache.xml -o gpsutil -F %TMPDIR%\navi.wpt +CALL :COMPARE %TMPDIR%\navi.wpt reference\navicache.ref +REM + +REM +REM Arc Distance filter +REM +DEL %TMPDIR%\arcdist.txt +%PNAME% -i xmap -f reference\arcdist_input.txt -x arc,file=reference\arcdist_arc.txt,distance=1 -o xmap -F %TMPDIR%\arcdist.txt +CALL :COMPARE %TMPDIR%\arcdist.txt reference\arcdist_output.txt + +REM +REM Polygon filter +REM +DEL %TMPDIR%\polygon.txt +%PNAME% -i xmap -f reference\arcdist_input.txt -x polygon,file=reference\polygon_allencty.txt -o xmap -F %TMPDIR%\polygon.txt +CALL :COMPARE %TMPDIR%\polygon.txt reference\polygon_output.txt + + + + +REM +REM This is nasty. If we have a dictionary handy, treat it as a list of +REM waypoints and reduce all the names to eight characters. Fewer chars +REM results in lost waypoints currently and that's a defect. +REM -- 2.30.2